package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.mapper.WorkLevelDefaultDataVoMapper;
import com.zb.service.WorkLevelDefaultDataVoService;
import com.zb.entity.WorkLevelDefaultData;
import org.springframework.stereotype.Service;


/**
 * @Author WEN
 * @Date 2024/4/16 0016
 **/
@Service
public class WorkLevelDefaultDataVoServiceImpl extends ServiceImpl<WorkLevelDefaultDataVoMapper, WorkLevelDefaultData> implements WorkLevelDefaultDataVoService {

    // 保存工单默认级别
    @Override
    public void saveWorkDefaultLevel(Long custAccId) {
        QueryWrapper<WorkLevelDefaultData> wrapper = new QueryWrapper<>();
        wrapper.select("id")
                .eq("cust_acc_id", custAccId)
                .eq("is_default_level", true)
                .last("LIMIT 1");
        WorkLevelDefaultData vo = this.getOne(wrapper);
        if (null != vo) {
            return;
        }
        vo = new WorkLevelDefaultData();
        vo.setId(IdWorker.getId());
        vo.setCustAccId(custAccId);
        vo.setName("普通");
        vo.setColor("");
        vo.setWeight(0);
        vo.setDisalbed(false);
        vo.setDefaultLevel(true);
        this.save(vo);
    }
}
